package com.hhs.FileUpload.controller;


import com.hhs.FileUpload.service.JiahunService;
import com.hhs.FileUpload.util.Result;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


import java.io.IOException;

@RestController
@RequestMapping("jianhuang")
public class JianHuangController {

    @Autowired
    private JiahunService jiahunService;


    // 这是一个处理文件上传的Spring MVC控制器方法
    @RequestMapping("jh")
    public Result aaa(@RequestParam("multipartFile") MultipartFile file) throws IOException {
        // 验证文件是否为空
        if (file.isEmpty()) {
            // 如果文件为空，返回错误或其他适当的响应
            return Result.success("文件为空");
        }
        boolean isYellow = jiahunService.tupian(file);
        // 返回结果
        return Result.success(isYellow);
    }


    @RequestMapping("jhsp")
    public Result bbb(@RequestParam("multipartFile") MultipartFile multipartFile) throws IOException {
        boolean isYellow = jiahunService.jianhuan(multipartFile);
        Result result = new Result();
        result.setData(isYellow);  // false  代表的正常的   true  代表的是黄色
        result.setMsg(isYellow ? "视频包含违规图片" : "视频是干净的");
        return result;
    }


}
